package com.cf.spider.core.model;

import com.cf.code.core.CField;
import com.cf.code.core.CModel;
import com.cf.code.core.CPage;
import com.cf.crud.entity.BaseEntity;

import javax.persistence.*;
import java.util.Date;

/**
 * boot-awm-JobTask
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/7/11 上午 10:01
 */
@Entity
@Table(name = "jobTask")
@CModel(pages = {
        @CPage(title = "抓取项列表", path = "jobTask", templateName = "list.ftl", outPutName = "list.ftl"),
        @CPage(title = "抓取项", path = "jobTask", templateName = "add.ftl", outPutName = "add.ftl"),
        @CPage(title = "抓取项", path = "jobTask", templateName = "update.ftl", outPutName = "update.ftl")
})
public class JobTask extends BaseEntity {

    /**
     * 任务Id
     */
    @Column(name = "jobId")
    @CField(lab = "任务Id")
    private long jobId;

    /**
     * 抓取地址
     */
    @CField(lab = "任务地址")
    private String url;

    /**
     * 任务的状态
     */
    @CField(lab = "任务状态")
    private String state = EnumJobState.PREPARE.getState();

    /**
     * 提取出来的数据
     */
    @CField(lab = "抓取的数据")
    private String data;

    /**
     * 数据尝试推送的时间
     */
    @Column(name = "fetchRetry")
    @CField(lab = "抓取重试次数")
    private int fetchRetry = 0;

    /**
     * 数据尝试推送的时间
     */
    @Column(name = "pushRetry")
    @CField(lab = "推送重试次数")
    private int pushRetry = 0;

    /**
     * 任务执行信息
     */
    @CField(lab = "信息")
    private String msg;

    /**
     * 最近的一次推送时间
     */
    @Column(name = "lastPushTime")
    @Temporal(TemporalType.TIMESTAMP)
    @CField(lab = "最近一次尝试时间", type = "date")
    private Date lastTryTime;


    @Override
    public String toString() {
        return "JobTask{" +
                "jobId=" + jobId +
                ", url='" + url + '\'' +
                ", state='" + state + '\'' +
                ", data='" + data + '\'' +
                ", fetchRetry=" + fetchRetry +
                ", pushRetry=" + pushRetry +
                ", lastTryTime=" + lastTryTime +
                '}';
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getJobId() {
        return jobId;
    }

    public void setJobId(long jobId) {
        this.jobId = jobId;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public Date getLastTryTime() {
        return lastTryTime;
    }

    public void setLastTryTime(Date lastTryTime) {
        this.lastTryTime = lastTryTime;
    }

    public int getFetchRetry() {
        return fetchRetry;
    }

    public void setFetchRetry(int fetchRetry) {
        this.fetchRetry = fetchRetry;
    }

    public int getPushRetry() {
        return pushRetry;
    }

    public void setPushRetry(int pushRetry) {
        this.pushRetry = pushRetry;
    }
}
